<!DOCTYPE html>
<html lang="en">
<head th:include="certificateWeb/headFoot :: headerCss">
</head>
<link rel="stylesheet" href="/css/certificateWeb/stationApplyFor/stationApplyFor.css">
<link rel="stylesheet" href="/css/plugins/bootstrap-table/bootstrap-table.min.css">
<body id="body">
<div th:include="certificateWeb/headFoot :: header"></div>
<style>
    .line {
        text-align: center;
        border-bottom: 1px solid #CFCFCF;
        clear: both;
        margin-top: 20px
    }

    .span_1 {
        width: 180px
    }
    .span_xz {
        width: 380px;
        height: 200px;
    }

    .cd {
        width: 130px;
        display: inline-block;
        margin: 20px auto auto auto;
    }

    .dong {
        width: 55px;
        display: inline-block;
        margin: 20px auto auto auto;
    }

    .jshi {
        width: 55px;
        display: inline-block;
        margin: 20px auto auto auto;
    }

    .addBtn {
        width: 440px;
        height: 35px;
        background-color: #dddee1;
        border-radius: 3px;
        margin: 20px auto 20px 95px;
        color: #515c34;
        font-weight: bold;
        border: 0px;
    }

    .del {
        width: 55px;
        color: #00b7ee;
        background-color: #dddee1;
        margin-left: 15px;
        display: inline-block;
        border-radius: 3px;
        text-align: center;
        font-size: 16px;
        line-height: 25px;
        margin-top: 34px;
    }
    .ss{
        display: flex;
        align-items: center;
        text-align: left !important;
        border-bottom: 1px solid #f6f6f6 !important;
    }
    .textli {
        width: 640px   !important;
        white-space: nowrap !important;
        text-overflow: ellipsis !important;
        overflow: hidden !important;
        margin: 0 !important;
    }
</style>
<main id="main">
    <section class="sec_1">
        <div class="div_1">
            <ul>
                <li  id="a1"><a href="/certificate/testingCentreApplyFor?type=5&profileType=0">幼儿照护考核站点申请</a></li>
                <li  id="a2"><a href="/certificate/testingCentreApplyFor?type=5&profileType=1">产后恢复考核站点申请</a></li>
                <li  id="b1"><a href="/certificate/testingCentreApplyForPx?type=1">培训基地申请</a></li>
                <li class="this"><a href="/certificate/declarationFrom">申报</a></li>
            </ul>
        </div>
        <div class="div_2" id="testingBox" style="padding: 0 20px;padding-bottom: 20px">
<!--            <div id="app">-->

<!--&lt;!&ndash;                <table id="docDateTable" class="table table-hover table-bordered" style="color: #000000">&ndash;&gt;-->
<!--&lt;!&ndash;                </table>&ndash;&gt;-->
<!--            </div>-->
        </div>
        <div style="clear: both"></div>
    </section>
</main>
<div th:include="certificateWeb/headFoot :: footer"></div>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script src="/js/plugins/validate/jquery.validate.extend.js"></script>
<script type="text/javascript" src="/js/jquery-form.js"></script>
<script type="text/javascript" src="/js/vue.min.js"></script>
<script type="text/javascript" src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript" src="/js/plugins/bootstrap-table/bootstrap-table-vue.min.js"></script>

<script src="/js/jquery.citys.js"></script>
</body>
<script>
    $(function () {
        ajaxToken("/jzApi/user/selUserDetail", "GET", {}, function (res) {
        });
        ajaxToken("/certificate/findTrainInfo", "Post", {}, function (res) {
            // declareCreate()
        })
        load()
    });

    async function load() {
        const res = await declareCreate()
        let span = document.createElement('ul');
        let links = '';
        for (let i = 0; i < res.length; i++) {

            console.log('declareStatus1111',res[i].declareStatus)
            //declareStatus  0 = 未审核，1 = 审核通过 2 = 审核拒绝
            let a= Number(res[i].declareStatus)==5?`<a class="btn btn-primary btn-sm operateBtn"  href="#" mce_href="#" onclick="edit('${res[i].id}','${res[i].declareStatus}')">申报申请</a>`:
                   Number(res[i].declareStatus)==0?`<a class="btn btn-primary btn-sm operateBtn"  href="#" mce_href="#" onclick="edit('${res[i].id}','${res[i].declareStatus}')">等待审核</a>`:
                   Number(res[i].declareStatus)==1?`<a class="btn btn-primary btn-sm operateBtn"  href="#" mce_href="#" onclick="edit('${res[i].id}','${res[i].declareStatus}')">审核通过</a>`:
                       `<a class="btn btn-primary btn-sm operateBtn"  href="#" mce_href="#" onclick="edit('${res[i].id}','${res[i].declareStatus}')">审核拒绝</a>`
            let x = `<li class="ss"><p class="textli">${res[i].title}</p> ${a}</li>`;
            // let x = `<li class="ss"><p class="textli">${res[i].title}</p> </li>`;
            links += x

        }
        console.log(span)
        span.innerHTML = links;
        $('#testingBox').html(span)
    }
    function edit(id,declareStatus) {
        console.log('declareStatus',declareStatus)
        location.href = `/certificate/declarationParticulars?id=${id}&declareStatus=${declareStatus}`
    }

    function formatTableUnit(value, row, index) {
        return {
            css: {
                "white-space": 'nowrap',
                "text-overflow": "ellipsis",
                "overflow": "hidden",
                "max-width":"100px"
            }
        }
    }

    // 查询所有申报
    function declareCreate(){
        return new Promise(function (resolve, reject){
            $.ajax({
                type : "get",
                url : `/jzweb/declareReady/getList`,
                async : false,
                beforeSend: function (request) {
                    request.setRequestHeader("Authorization", window.localStorage.getItem("token"))
                },
                error : function(request) {
                    layer.msg('错误')
                },
                success : function(res) {
                    if (res.code === '0') {
                        resolve(res.data.records)
                    } else {
                        reject(res)
                    }

                }
            });
        })
    }

</script>
</html>